package com.loong.android.views.utils;

public class GravityUtils {
    //默认
    public final static int DEFAULT = 0;
    //靠左
    public final static int LEFT = 1;
    //靠右
    public final static int RIGHT = 2;
    //靠上
    public final static int TOP = 3;
    //靠下
    public final static int BOTTOM = 4;
    //水平居中
    public final static int CENTER_X = 5;
    //垂直居中
    public final static int CENTER_Y = 6;
    //左上
    public final static int TOP_LEFT = 7;
    //中上
    public final static int TOP_CENTER = 8;
    //右上
    public final static int TOP_RIGHT = 9;
    //左中
    public final static int MIDDLE_LEFT = 10;
    //居中
    public final static int CENTER = 11;
    //右中
    public final static int MIDDLE_RIGHT = 12;
    //左下
    public final static int BOTTOM_LEFT = 13;
    //中下
    public final static int BOTTOM_CENTER = 14;
    //右下
    public final static int BOTTOM_RIGHT = 15;

    public static int getGravity(int g) {
        switch (g) {
            case LEFT:
                return LonGravity.LEFT;
            case RIGHT:
                return LonGravity.RIGHT;
            case TOP:
                return LonGravity.TOP;
            case BOTTOM:
                return LonGravity.BOTTOM;
            case CENTER_X:
                return LonGravity.CENTER_HORIZONTAL;
            case CENTER_Y:
                return LonGravity.CENTER_VERTICAL;
            case TOP_LEFT:
                return LonGravity.TOP | LonGravity.LEFT;
            case TOP_CENTER:
                return LonGravity.TOP | LonGravity.CENTER_HORIZONTAL;
            case TOP_RIGHT:
                return LonGravity.TOP | LonGravity.RIGHT;
            case MIDDLE_LEFT:
                return LonGravity.CENTER_VERTICAL | LonGravity.LEFT;
            case CENTER:
                return LonGravity.CENTER;
            case MIDDLE_RIGHT:
                return LonGravity.CENTER_VERTICAL | LonGravity.RIGHT;
            case BOTTOM_LEFT:
                return LonGravity.BOTTOM | LonGravity.LEFT;
            case BOTTOM_CENTER:
                return LonGravity.BOTTOM | LonGravity.CENTER_HORIZONTAL;
            case BOTTOM_RIGHT:
                return LonGravity.BOTTOM | LonGravity.RIGHT;
        }
        return 0;
    }

    public static int toAMixGravity(int g) {
        switch (g) {
            case LonGravity.LEFT:
                return LEFT;
            case LonGravity.RIGHT:
                return RIGHT;
            case LonGravity.TOP:
                return TOP;
            case LonGravity.BOTTOM:
                return BOTTOM;
            case LonGravity.CENTER_HORIZONTAL:
                return CENTER_X;
            case LonGravity.CENTER_VERTICAL:
                return CENTER_Y;
            case LonGravity.TOP | LonGravity.LEFT:
                return TOP_LEFT;
            case LonGravity.TOP | LonGravity.CENTER_HORIZONTAL:
                return TOP_CENTER;
            case LonGravity.TOP | LonGravity.RIGHT:
                return TOP_RIGHT;
            case LonGravity.CENTER_VERTICAL | LonGravity.LEFT:
                return MIDDLE_LEFT;
            case LonGravity.CENTER:
                return CENTER;
            case LonGravity.CENTER_VERTICAL | LonGravity.RIGHT:
                return MIDDLE_RIGHT;
            case LonGravity.BOTTOM | LonGravity.LEFT:
                return BOTTOM_LEFT;
            case LonGravity.BOTTOM | LonGravity.CENTER_HORIZONTAL:
                return BOTTOM_CENTER;
            case LonGravity.BOTTOM | LonGravity.RIGHT:
                return BOTTOM_RIGHT;
        }
        return 0;
    }
}
